package com.example.tvwanandroid.presenter

import com.example.tvwanandroid.base.BaseListResult
import com.example.tvwanandroid.base.BaseObserver
import com.example.tvwanandroid.base.BasePresenter
import com.example.tvwanandroid.base.BaseResult
import com.example.tvwanandroid.bean.ProjectListBean
import com.example.tvwanandroid.bean.ProjectTitleBean
import com.example.tvwanandroid.view.ProjectView

/**
 * @作者: njb
 * @时间: 2020/12/9 10:03
 * @描述:
 */
class ProjectPresenter(baseView: ProjectView):BasePresenter<ProjectView>(baseView) {

    fun  getProjectTree(){
        addDisposable(apiServer.projectTree(),object :BaseObserver<BaseListResult<ProjectTitleBean.DataBean>>(baseView){
            override fun onSuccess(o: BaseListResult<ProjectTitleBean.DataBean>) {
                baseView.onLoadProjectTree(o.data!!)
            }

            override fun onError(msg: String?) {
                baseView.showError(msg!!)
            }

        })
    }

    fun getProjectList(page:Int,cid:Int){
        addDisposable(apiServer.projectList(page,cid),object :BaseObserver<BaseResult<ProjectListBean>>(baseView){
            override fun onSuccess(o: BaseResult<ProjectListBean>) {
                baseView.onLoadProjectTitle(o.data!!)
            }

            override fun onError(msg: String?) {
                baseView.showError(msg!!)
            }

        })
    }
}